Filters and External links

Hello again Dxlers,

I have a dxl script that generates views and looks for missing links. Just before finishing I ran a test that did not work with requirements with external links. 

How is the filter set up to detect external links?

best regards

Colm


MyDeveloerWorks - Tue Mar 11 17:48:50 EDT 2014

Re: Filters and External links
llandale - Wed Mar 12 11:15:37 EDT 2014

Don't recall if you can do it directly.  But you can certainly:

  • "HasExternalLink" - boolean Attr-DXL, true if the object has an external link
    • bool Has = false
    • for every external link; Has = true
    • obj.attrDXLName = Has
  • Filter on that attribute.

-Louie

Re: Filters and External links
MyDeveloerWorks - Thu Mar 13 06:13:55 EDT 2014

llandale - Wed Mar 12 11:15:37 EDT 2014

Don't recall if you can do it directly.  But you can certainly:

  • "HasExternalLink" - boolean Attr-DXL, true if the object has an external link
    • bool Has = false
    • for every external link; Has = true
    • obj.attrDXLName = Has
  • Filter on that attribute.

-Louie

Hello Louie,.

I tried going the iteration as follows, but all my attributes stayed at false, despite some having external links
bool Has= false
Object o = current
ExternalLink el 
//Iterate over outward links 
for el in o->"" do  
{ 
 Has = true
}
o.attrDXLName = Has

Re: Filters and External links
sekrbo - Thu Mar 13 08:16:28 EDT 2014

MyDeveloerWorks - Thu Mar 13 06:13:55 EDT 2014

Hello Louie,.

I tried going the iteration as follows, but all my attributes stayed at false, despite some having external links
bool Has= false
Object o = current
ExternalLink el 
//Iterate over outward links 
for el in o->"" do  
{ 
 Has = true
}
o.attrDXLName = Has

Well the DXL Help says:

for all outgoing external links
Declaration
for extLink in (Object o) -> string ""
where:
extLink is a variable of type ExternalLink

ExternalLink el
Object o
bool bHas

for o in current Module do {
    bHas = false
    for el in o -> "" do {
        bHas = true
    }
    print identifier (o) ": " bHas "\n"
}

That works for me...

/sekrbo

Re: Filters and External links
MyDeveloerWorks - Thu Mar 13 10:07:21 EDT 2014

MyDeveloerWorks - Thu Mar 13 06:13:55 EDT 2014

Hello Louie,.

I tried going the iteration as follows, but all my attributes stayed at false, despite some having external links
bool Has= false
Object o = current
ExternalLink el 
//Iterate over outward links 
for el in o->"" do  
{ 
 Has = true
}
o.attrDXLName = Has

In the end I got this to work.  

I also forgot to execute the menu item "refresh dxl Attributes"

bool Has= false
Object o = current
ExternalLink el 
//Iterate over outward links 
for el in o->"" do  
{ 
 Has = true
}
for el in o<-"" do  
{ 
 Has = true
}
o.attrDXLName = Has

Re: Filters and External links
MyDeveloerWorks - Thu Mar 13 10:10:05 EDT 2014

sekrbo - Thu Mar 13 08:16:28 EDT 2014

Well the DXL Help says:

for all outgoing external links
Declaration
for extLink in (Object o) -> string ""
where:
extLink is a variable of type ExternalLink

ExternalLink el
Object o
bool bHas

for o in current Module do {
    bHas = false
    for el in o -> "" do {
        bHas = true
    }
    print identifier (o) ": " bHas "\n"
}

That works for me...

/sekrbo

Thanks for the contribution Sekrbo. That code was useful for testing in the dxl editor.

 

 

Re: Filters and External links
sekrbo - Thu Mar 13 10:37:55 EDT 2014

MyDeveloerWorks - Thu Mar 13 10:07:21 EDT 2014

In the end I got this to work.  

I also forgot to execute the menu item "refresh dxl Attributes"

bool Has= false
Object o = current
ExternalLink el 
//Iterate over outward links 
for el in o->"" do  
{ 
 Has = true
}
for el in o<-"" do  
{ 
 Has = true
}
o.attrDXLName = Has

Well since it's a DXL attribute you're working on you can skip the Object o = current, as the variable obj is already defined as the current object... thus giving you:

bool Has= false
ExternalLink el
//Iterate over outward links
for el in obj->"" do
{
    Has = true
}
for el in obj<-"" do
{
    Has = true
}
obj.attrDXLName = Has

/sekrbo

Re: Filters and External links
llandale - Thu Mar 13 16:41:47 EDT 2014

sekrbo - Thu Mar 13 10:37:55 EDT 2014

Well since it's a DXL attribute you're working on you can skip the Object o = current, as the variable obj is already defined as the current object... thus giving you:

bool Has= false
ExternalLink el
//Iterate over outward links
for el in obj->"" do
{
    Has = true
}
for el in obj<-"" do
{
    Has = true
}
obj.attrDXLName = Has

/sekrbo

In fact, Object o = current is incorrect, not just "can be skipped".

I point out that the attribute needs to be defined as Boolean.

-Louie

Re: Filters and External links
M_vdLaan - Wed Mar 19 11:10:12 EDT 2014

sekrbo - Thu Mar 13 10:37:55 EDT 2014

Well since it's a DXL attribute you're working on you can skip the Object o = current, as the variable obj is already defined as the current object... thus giving you:

bool Has= false
ExternalLink el
//Iterate over outward links
for el in obj->"" do
{
    Has = true
}
for el in obj<-"" do
{
    Has = true
}
obj.attrDXLName = Has

/sekrbo

A minor point, perhaps, but there's an optimization possible here, certainly if objects can have multiple links: 

bool Has= false
ExternalLink el
//Iterate over outward links
for el in obj->"" do
{
    Has = true
    break // Stop looking, we've found one...
}
if (!Has) { // Don't bother if we already found an outgoing link
    for el in obj<-"" do
    {
        Has = true
        break // Stop looking, we've found one...
    }    
}
obj.attrDXLName = Has

 

Just one thing (cannot check it now): should the obj->"" and obj<-"" include the asterisk, i.e. obj->"*" and obj<-"*"?

 

Regards,

Marcel